﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using 财会系.admin;
using Bll;
using Model;

namespace 财会系
{
    public partial class ckx : System.Web.UI.Page
    {
        string strUserAcc = "";
        string strUserName = "";
        string strUserGrade = "";
        string strUserType = "";
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if(openNum.InnerText=="0")
                {
                    if (Session["admin"] != null)
                    {
                        UserAdmin.InnerText = Session["admin"].ToString();
                    }
                    openNum.InnerText = "1";
                }

                
                if (UserAdmin.InnerText=="")
                {
                    Response.Redirect("./login.aspx");
                }
                else
                {
                    strUserAcc = Session["admin"].ToString();
                    strUserName = Session["Name"].ToString();
                    strUserGrade = Session["Grade"].ToString();
                    strUserType= Session["Type"].ToString();
                    
                    Content();
                    UserGradeBind();

                    if (strUserName=="")
                        UserName.InnerText = strUserAcc;
                    else
                        UserName.InnerText = strUserName;

                    UserType.InnerText = strUserType;
                }
            }
        }
        private void Content()
        {
            BllBackground b = new BllBackground();
            DataTable dt = b.Nav_Name_All();

            Nav_List.DataSource = dt;
            Nav_List.DataBind();
        }

        private void UserGradeBind()
        {
            BllAdmin b = new BllAdmin();
            ModelAdmin m = new ModelAdmin();
            if(Session["Admin"]!=null)
            {
                m.Acc = Session["Admin"].ToString();
                UserGrade.InnerText = b.Admin_Grade(m);
            }
            
        }
    }
}